package com.david.http

import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.TextView
import androidx.activity.ComponentActivity
import com.david.http.http.util.request
import com.david.http.http.method.test.methodTestInterface
import com.david.http.http.method.test1.methodTest1Interface

/**
 * rxJava3 + retrofit封装请求
 */
class HttpTestMainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        findViewById<View>(R.id.request).setOnClickListener {
            methodTestInterface.test().request(this) {
                Log.e("http", "result is $it")
                findViewById<TextView>(R.id.request).text = it.data?.name
            }

            methodTest1Interface.testArr().request(this) {
                Log.e("http", "result is $it")
//                findViewById<TextView>(R.id.request).text = it.data?.name
            }
//            createRfInterface(IMainInterface::class.java).test()
//                .observe(this) {
//                    Log.e("http", "result is $it")
//                    findViewById<TextView>(R.id.request).text = it
//                }

//            retrofitHelper.getRetrofit("http://192.168.1.104:8080").create(IMainInterface::class.java).test().observe(this) {
//                Log.e("http", "result is $it")
//            }
        }
    }
}